# -*- coding: utf-8 -*-
"""
@Time : 2024/10/27 22:31
@Author : 仰望天空的蜗牛
@Email : middlegod@sina.com
@File : app.py
"""
import time

from get_live_weibo_search import get_weibo_search
from speaker import speaker


def main():
    search_keyword = 'python'
    mblogs = get_weibo_search(search_keyword)
    if mblogs:
        for mblog in mblogs:
            time.sleep(3)
            speaker(f"以下内容来自微博用户{mblog.get('user_name')}，关于{search_keyword}的最新微博")
            time.sleep(1)
            speaker(mblog.get('title'))
    else:
        speaker("本次未搜索到最新博文。")


if __name__ == '__main__':
    while True:
        main()
        waiting_time = 10*60
        speaker(f"等待{int(waiting_time/60)}分钟后，再进行微博实时查询结果的播报。")
        time.sleep(waiting_time)
